//
//  WYHotIndustryViewCell.m
//  Boss
//
//  Created by admin on 2018/7/19.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYHotIndustryViewCell.h"
#import "SCAdView.h"
#import "CJHumanCell.h"
@interface WYHotIndustryViewCell()<SCAdViewDelegate>{
    SCAdView *_adView;
}
@property (strong, nonatomic) IBOutlet UIView *mainView;

@end
@implementation WYHotIndustryViewCell
-(void)setDataArray:(NSMutableArray *)dataArray
{
    _dataArray = dataArray;
    [self showAdHorizontally];
}
-(void)showAdHorizontally{
//    NSArray *testArray =@[@"刘备",@"李白",@"嬴政",@"韩信"];
//    //模拟服务器获取到的数据
//    NSMutableArray *arrayFromService  = [NSMutableArray array];
//    for (NSString *text in testArray) {
//        HeroModel *hero = [HeroModel new];
//        hero.imageName = text;
//        hero.introduction = [NSString stringWithFormat:@"我是王者农药的:---->%@",text];
//        [arrayFromService addObject:hero];
//    }
    SCAdView *adView = [[SCAdView alloc] initWithBuilder:^(SCAdViewBuilder *builder) {
        builder.adArray = self.dataArray;
        builder.viewFrame = (CGRect){0,0,kScreenWidth,100};
        builder.adItemSize = (CGSize){kScreenWidth/3.0f,100};
        builder.minimumLineSpacing = 0;
        builder.secondaryItemMinAlpha = -1;
        builder.threeDimensionalScale = 1.40;
        builder.itemCellNibName = @"CJHumanCell";
    }];
    adView.backgroundColor = [UIColor yellowColor];
    adView.delegate = self;
    _adView = adView;
    [self.mainView addSubview:adView];
    
    [adView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.top.mas_equalTo(0);
    }];
    
}
#pragma mark -delegate

-(void)sc_didClickAd:(id)adModel{
    NSLog(@"sc_didClickAd-->%@",adModel);
//    if ([adModel isKindOfClass:[HeroModel class]]) {
//        NSLog(@"%@",((HeroModel*)adModel).introduction);
//    }
    if ([self.delegate respondsToSelector:@selector(didCellImageViewWithModel:)]) {
        [self.delegate didCellImageViewWithModel:adModel];
    }
}

-(void)sc_scrollToIndex:(NSInteger)index{
    NSLog(@"sc_scrollToIndex-->%ld",index);
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
